package com.mycompany.app.common.extmenu.action;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.HashSet;

import com.mycompany.app.common.extmenu.IExtTreeProvider;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class ExtMenuAction extends ActionSupport {

    IExtTreeProvider extTreeProvider;

    public void setExtTreeProvider(IExtTreeProvider extTreeProvider) {

        this.extTreeProvider = extTreeProvider;
    }

    private InputStream inputStream;

    public InputStream getInputStream() {

        return inputStream;
    }

    public String getMenu() {
        HashSet<String> auths = new HashSet<String>();
        auths.add("AUTH_MAPPING_FULL");
        
        inputStream = new ByteArrayInputStream(
                extTreeProvider.provide(auths, "zh").getBytes());
        return Action.SUCCESS;
    }

}
